FROM golang:1.17.5-alpine3.15 as builder

ARG goproxy
RUN apk add make && apk add git

RUN git clone git://github.com/flike/kingshard.git  /go/src/github.com/flike/kingshard
RUN cd /go/src/github.com/flike/kingshard && source ./dev.sh && make
RUN cp /go/src/github.com/flike/kingshard/etc/ks.yaml /etc/ks.yaml

RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories && apk --update add --no-cache tzdata git

# 创建空镜像 
FROM alpine:latest
COPY --from=builder /etc/ /etc/
COPY --from=builder /go/src/github.com/flike/kingshard/bin /bin/
EXPOSE 3306
EXPOSE 9797
ENTRYPOINT ["/bin/kingshard"]

